#include<iostream>
#include<assert.h>
using namespace std;
typedef int T;
typedef struct BSTNode
{
	T data;
	BSTNode* lchild;
	BSTNode* rchild;
}BSTNode;
typedef struct BST
{
	BSTNode* root;
}BST;
void Init_BST(BST* t)
{
	t->root = NULL;
}
bool Insert_BST(BSTNode**B, T x)
{
	if (*B == NULL)
	{
		*B = (BSTNode*)malloc(sizeof(BSTNode));
		assert(*B);
		(*B)->data = x;
		(*B)->lchild = (*B)->rchild = NULL;
		return true;
	}
	else if ((*B)->data < x)
	{
		return Insert_BST(&(*B)->lchild, x);
	}
	else
	{
		return Insert_BST(&(*B)->rchild, x);
	}
	return false;
}
bool Insert_BST(BST* t,T x)
{
	return Insert_BST(&(t->root), x);
}
T Min_BST(BSTNode* t)
{
	if (t->lchild != NULL) {
		t = t->lchild;
	}
	return t->data;
}
T Min_BST(BST* t)
{
	assert(t->root!=NULL);
	return Min_BST(t->root);
}
int main()
{
	BST bst;
	Init_BST(&bst);
	int arr[] = { 13,23,43,5,32,65,46,67 };
	int sz = sizeof(arr) / sizeof(arr[0]);
	for (int i = 0; i < sz; i++)
	{
		Insert_BST(&bst,arr[i]);
	}
	T temp = Min_BST(&bst);
	return 0;
}